<template>

	<view class="article">
		<!-- #ifdef APP-PLUS -->
		<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar>
		<!-- #endif -->
		<view class="article-title">{{ infoData.chepaihao }}</view>
				<uni-list :border="false">
					<uni-list-item title="车牌号" :rightText="infoData.chepaihao"/>
					<uni-list-item title="姓名" :rightText="infoData.xingming"/>
					<uni-list-item title="出单人" :rightText="infoData.chudanren"/>
					<uni-list-item title="创建日期" :rightText="infoData.createTime"/>
					<uni-list-item title="单号" :rightText="infoData.danhao"/>
					<uni-list-item title="第N单" :rightText="infoData.dindan"/>
					<uni-list-item title="支付" :rightText="infoData.zhifu"/>
					<uni-list-item title="状态" :rightText="infoData.zhuangtai"/>
					<uni-list-item title="费用" :rightText="infoData.feiyong + ''"/>
					<uni-list-item title="高速" :rightText="infoData.gaosu"/>
					<uni-list-item title="经费" :rightText="infoData.jingfei+''"/>
					<uni-list-item title="净收" :rightText="infoData.jingshou+''"/>
					<uni-list-item title="签约" :rightText="infoData.qianyue"/>
					<uni-list-item title="日期" :rightText="infoData.riqi"/>
					<uni-list-item title="上家" :rightText="infoData.shangjia"/>
					<uni-list-item title="下家" :rightText="infoData.xiajia"/>
					<uni-list-item title="手机号" :rightText="infoData.shoujihao"/>
					<uni-list-item title="所属部门" :rightText="infoData.sysOrgCode"/>
					<uni-list-item title="更新日期" :rightText="infoData.updateTime"/>
					<uni-list-item title="序号" :rightText="infoData.xuhao"/>
					<uni-list-item title="银行" :rightText="infoData.yinhang"/>
					<uni-list-item title="邮寄地址" :note="infoData.youjidizhi"/>
				</uni-list>
				<!-- <view class="article-content">
					<rich-text :nodes="infoData.content"></rich-text>
				</view> -->
	</view>
</template>

<script>
	// #ifdef APP
	import UniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
	import uniNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue';
	const uniShare = new UniShare()
	// #endif
	export default {
		// #ifdef APP
		components:{
			"uni-nav-bar":uniNavBar
		},
		onBackPress({from}) {
			if(from == 'backbutton'){
				if(uniShare.isShow){
					this.$nextTick(function(){
						console.log(uniShare);
						uniShare.hide()
					})
				}
				return uniShare.isShow;
			}
		},
		// #endif
		data() {
			return {
				// 当前显示 _id
				id: "",
				title: 'title',
				infoData:{}, // 详情
			}
		},
		computed: {
			uniStarterConfig() {
				return getApp().globalData.config
			},
			
		},
		onLoad(event) {
			//获取真实新闻id，通常 id 来自上一个页面
			if (event.id) {
				this.id = event.id
			}
			//若上一页传递了标题过来，则设置导航栏标题
			if (event.title) {
				this.title = event.title
				uni.setNavigationBarTitle({
					title: event.title
				})
			}
		},
		onReady() {
			// 开始加载数据，需要等组件渲染完毕后才开始执行 loadData，所以不能再 onLoad 中执行
			if (this.id) { // ID 不为空，则发起查询
				this.loadData()
			} else {
				uni.showToast({
					icon: 'none',
					title: this.$t('listDetail.newsErr')
				})
			}
		},
		onNavigationBarButtonTap(event) {
			if (event.type == 'share') {
				this.shareClick();
			}
		},
		methods: {
			$log(...args){
				console.log('args',...args,this.id)
			},
			
			load(){
				
			},
			
			loadData(data) {
				//如果上一页未传递标题过来（如搜索直达详情），则从新闻详情中读取标题
				if (this.title == '' && data[0].title) {
					this.title = data[0].title
					uni.setNavigationBarTitle({
						title: data[0].title
					});

				}
				
				this.$api.etctzXyInfo({id:this.id}).then(res=>{
					console.log("res",res)
					this.infoData = res
				})
			},
			/**
			 * followClick
			 * 点击关注
			 */
			followClick() {
				uni.showToast({
					title:this.$t('listDetail.follow'),
					icon: 'none'
				});
			},
			/**
			 * 分享该文章
			 */
			// #ifdef APP
			shareClick() {
				let {
					_id,
					title,
					excerpt,
					avatar
				} = this.$refs.detail.dataList
				console.log( JSON.stringify({
					_id,
					title,
					excerpt,
					avatar
				}) );
				uniShare.show({
					content: { //公共的分享类型（type）、链接（herf）、标题（title）、summary（描述）、imageUrl（缩略图）
						type: 0,
						href: this.uniStarterConfig.h5.url + `/#/pages/list/detail?id=${_id}`,
						title: this.title,
						summary: excerpt,
						imageUrl: avatar + '?x-oss-process=image/resize,m_fill,h_100,w_100' //压缩图片解决，在ios端分享图过大导致的图片失效问题
					},
					menus: [{
							"img": "/static/app-plus/sharemenu/wechatfriend.png",
							"text": this.$t('common.wechatFriends'),
							"share": {
								"provider": "weixin",
								"scene": "WXSceneSession"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/wechatmoments.png",
							"text": this.$t('common.wechatBbs'),
							"share": {
								"provider": "weixin",
								"scene": "WXSceneTimeline"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/mp_weixin.png",
							"text": this.$t('common.wechatApplet'),
							"share": {
								provider: "weixin",
								scene: "WXSceneSession",
								type: 5,
								miniProgram: {
									id: this.uniStarterConfig.mp.weixin.id,
									path: `/pages/list/detail?id=${_id}`,
									webUrl: this.uniStarterConfig.h5.url +
										`/#/pages/list/detail?id=${_id}`,
									type: 0
								},
							}
						},
						{
							"img": "/static/app-plus/sharemenu/weibo.png",
							"text": this.$t('common.weibo'),
							"share": {
								"provider": "sinaweibo"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/qq.png",
							"text": "QQ",
							"share": {
								"provider": "qq"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/copyurl.png",
							"text": this.$t('common.copy'),
							"share": "copyurl"
						},
						{
							"img": "/static/app-plus/sharemenu/more.png",
							"text": this.$t('common.more'),
							"share": "shareSystem"
						}
					],
					cancelText: this.$t('common.cancelShare'),
				}, e => { //callback
					console.log(e);
				})
			}
			// #endif
		}
	}
</script>

<style scoped>
	
	

	.article-title {
		padding: 20px 15px;
		padding-bottom: 0;
	}

	.article-content {
		padding: 15px;
		font-size: 15px;
		overflow: hidden;
	}
</style>
